qx.Class.define("caraffa.forms.ChartOSCobradoPagado",
{
	extend : qx.ui.form.ow.FormTab,

	construct : function ()
	{
		this.base(arguments, "ChartOSCobradoPagado", "Est: OS. Diferencia Cobro");
		
		this._grpChart = new qx.ui.groupbox.GroupBox();
  		this._GC.setWidth(800);
  		this._GC.setLayout(new qx.ui.layout.Basic());
		
		this._txdFecha = new qx.ui.form.ow.DateText("Fecha a mostrar:");
			this._txdFecha.getDateText().setWidth(120);
		this._imgChartOSCP = new qx.ui.basic.Image("");
		
		this._layLabelsOS = new qx.ui.container.Composite(new qx.ui.layout.VBox(5)).set({width:150});
		
		this._GC.add(this._txdFecha, {left:0, top:0});
		this._GC.add(this._imgChartOSCP, {left:0, top:50});
		this._GC.add(this._layLabelsOS, {left:470, top:210});

		this._attachEvents();
		
		this.add(this._GC, {left:10, top:10});
		
		this._imgChartOSCP.setSource("reports/OSCobradoPagado.php?fecha=" + this._txdFecha.getValue());
		this._getObrasSociales();
	},
	members :
	{
		_attachEvents : function ()
		{
			this._txdFecha.getDateText().addListener("changeValue", function ()
			{
				this._imgChartOSCP.setSource("reports/OSCobradoPagado.php?fecha=" + this._txdFecha.getValue());
			}, this);
		},
		_getObrasSociales : function ()
		{
			var rpc = new qx.io.remote.Rpc();
			rpc.setTimeout(10000);
			rpc.setUrl("services/");
			rpc.setServiceName("Charts");
			try
			{
				var result = rpc.callSync("getObrasSociales");
				for (var i in result)
				{
					this._layLabelsOS.add(new qx.ui.basic.Label(result[i].os));
				}
			}
			catch (ex)
			{
				alert(ex);
			}
		}
	}
});
